package by.admonko.universaltesting.services.impl;

import java.util.Date;
import java.util.List;

import javax.inject.Inject;

import org.springframework.stereotype.Service;

import by.admonko.universaltesting.dataaccess.TestResultDao;
import by.admonko.universaltesting.datamodel.Test;
import by.admonko.universaltesting.datamodel.TestResult;
import by.admonko.universaltesting.datamodel.UserGroup;
import by.admonko.universaltesting.datamodel.UserTbl;
import by.admonko.universaltesting.services.TestResultService;

@Service
public class TestResultServiceImpl implements TestResultService {
	@Inject
	TestResultDao testResDao;

	@Override
	public void setTestResult(TestResult testResult) {
		testResDao.insert(testResult);

	}

	@Override
	public TestResult getTestResult(Integer id) {

		return testResDao.getById(id);
	}

	@Override
	public List<TestResult> getAllTestResult() {
		return testResDao.getAll();
	}

	@Override
	public List<TestResult> getTestResultByUserGroup(UserGroup userGroup) {

		return testResDao.getByUserGroup(userGroup);
	}

	@Override
	public List<TestResult> getTestResultByUser(UserTbl user) {

		return testResDao.getByUser(user);
	}

	@Override
	public List<TestResult> getTestResultByDate(Date date) {
		return testResDao.getByDate(date);
	}

	@Override
	// Cascade
	public void removeTestResult(Integer id) {
		testResDao.delete(id);
		// !!!!!!!!!!!!!!!!!!!

	}

	@Override
	// Cascade
	public void removeTetResultList(List<Integer> list) {
		// TODO Create!!!!!!!!!!!!!!1

	}

	@Override
	public void updateTestResult(TestResult testResult) {
		testResDao.update(testResult);

	}

	@Override
	public List<TestResult> getTestResultByTest(Test test) {
		return testResDao.getByTest(test);

	}
}
